Skip to content

04.Running commands

NOTE For this lab, you need PowerShell v7 or later running on Windows, macOS, or Linux.

Using what you learned in this chapter, and in the previous chapter on using the help system, complete the following tasks in PowerShell:

  1. Display a list of running processes.
  2. Test the connection to google.com or bing.com without using an external command like ping.
  3. Display a list of all commands that are of the cmdlet type. (This is tricky—we’ve shown you Get-Commandbut you need to read the help to find out how to narrow down the list as we’ve asked.)
  4. Display a list of all aliases.
  5. Make a new alias, so you can run ntst to run netstat from a PowerShell prompt.
  6. Display a list of processes that begin with the letter p. Again, read the help for the necessary command—and don’t forget that the asterisk (*) is a near-universal wildcard in PowerShell.
  7. Make a new folder (aka directory) using the New-Item cmdlet with the name of MyFolder1. Then do it again and call it MyFolder2. Use Help if you’re not familiar with New-Item.
  8. Remove the folders from step 7 in a single command. Use Get-Command to find a similar cmdlet to what we used in step 7—and don’t forget that the asterisk (*) is a near-universal wildcard in PowerShell.

We hope these tasks seem straightforward to you. If so—excellent. You’re taking advantage of your existing command-line skills to make PowerShell perform a few practical tasks for you. If you’re new to the command-line world, these tasks are a good introduction to what you’ll be doing in the rest of this book.

最近更新